Anatomy of a Controller
A regular module or main project must dependent on following libraries:
Mobiroller.Server.Web.Core
Mobiroller.Shared.Models
Mobiroller.Shared.Exceptions
Structure
- Each controller must inherit from
BaseController
from Mobiroller.Server.Web.Core
using Mobiroller.Server.Web.Core.Controllers;
//...
public class MyController : BaseController
{
//...
}
- Each Action must be use
ProduceResponseAttribute
attribute from Mobiroller.Server.Web.Core:
using Mobiroller.Server.Web.Core.Attributes;
//...
public class MyController : BaseController
{
[ProducesResponse(typeof(string[], 200))] // <-- Response Type must be defined with this attribute.
[HttpGet]
public IActionResult Get()
{
return Ok(new[] { "Value1", "Value2" });
}
}